<?php
namespace app\admin\controller;
use think\Loader;
use think\Controller;
class Adport  extends Controller {

    //后台登录 api
    public function accountLog()
    {
        $invoking     = Loader::model('Adport','service');
        $username     = trim(input('admin_account'));
        $password     = trim(input('admin_password'));
        $verification = trim ( input( 'verification' ) );
        $response         = $invoking->registerApi($username,$password,$verification);
        return json($response);
    }


    //退出登录
    public function quit(){
        session('Admin_user_lvtuan',null);
        session('wyrolelist_lvtuan',null);
        session('LVTUAN_NAME',null);
        $this->redirect(config('tempredirect_url').'admin');
    }





    //图片上传
    public function imgUploads(){
        $imgtype = input('imgtype');
        try {
            $imgtype = $imgtype?$imgtype:'img';
            $file = request()->file("file");
            $move = ROOT_PATH . 'public' . DS . 'uploads/'.$imgtype;
            $info =$file->validate(['ext'=>'jpg,png,gif'])->move($move);
            if($info){
                $url     = config('tempredirect_url').'uploads/'.$imgtype.'/'.$info->getSaveName();
                $response = messageInfo('202','上传成功','',$url);
            }else{
                // 上传失败获取错误信息
                $error = $file->getError();
                $response = messageInfo('101', $error);
            }
        } catch (\Exception  $e) {
            $response = messageInfo('101','服务器错误');
        }
        return json($response);
    }
}
